package com.blog.wl2023.controller.com;

import com.blog.wl2023.entity.response.Result;
import com.blog.wl2023.service.com.OtherComService;
import com.blog.wl2023.utils.note.ResponseResult;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author wule
 * @date 2023-12-08  17:28
 * @desc
 */
@RestController
@RequestMapping("api/otherCom")
@ResponseResult
@Log4j2
public class OtherComController {

	@Autowired
	OtherComService otherComService;

	private final RestTemplate restTemplate;

	public OtherComController(RestTemplate restTemplate) {
		this.restTemplate = restTemplate;
	}


	/**
	 * 获取所有网站数据
	 * @return TreasureChests数组
	 */
	@GetMapping("getSiteInfos")
	public Result getSiteInfos(){
		return otherComService.getSiteInfos();
	}




	/**
	 * 获取第三方api返回内容
	 * @param  api 接口地址
	 * @return 内容
	 */
	@GetMapping("getSayingsByApi")
	public Result getSayingsByApi(String api){
		String forObject = restTemplate.getForObject(api, String.class);
		return Result.ok(forObject);
	}


}
